package cn.hncj.lyc.controller.front;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.hncj.lyc.bean.OrderDetail;
import cn.hncj.lyc.bean.OrderManagement;
import cn.hncj.lyc.bean.UserInfo;
import cn.hncj.lyc.service.ConsigneeManagementService;
import cn.hncj.lyc.service.OrderManagementService;


/**
 * 前端订单管理
 * 
 * @author Administrator
 *
 */
@Controller
@RequestMapping("/")
public class OrderManagementController {
	@Autowired
	private ConsigneeManagementService cmService;
	@Autowired
	private OrderManagementService omService;
	
	@RequestMapping("showorder")
	public String showorder() {
		return "front/ordermanager_index";
	}
	
	
	/**
	 * 查询订单
	 * @param om
	 * @param session
	 * @param model
	 * @return
	 */
	@RequestMapping("queryOrderNo")
	public String queryOrder(OrderManagement om,HttpSession session,Model model){
		UserInfo user = (UserInfo) session.getAttribute("loginuser");
		
		if(user!=null){			
			//if(om==null){
				//om = new OrderManagement();
				om.setUserId(user.getUserId());
			//}			
			List<Map> list = omService.listNo(om);	
			model.addAttribute("list", list);			
		}		
		
		return "front/ordermanagerno_info";
	}
	/**
	 * 订单管理的业务逻辑接口
	 */
	@RequestMapping("queryOrderOk")
	public String list(OrderManagement om,HttpSession session,Model model ){
           UserInfo user = (UserInfo) session.getAttribute("loginuser");
		
		  if(user!=null){			
			//if(om==null){
				//om = new OrderManagement();
				om.setUserId(user.getUserId());
			//}			
			List<Map> list = omService.listOk(om);	
			model.addAttribute("list", list);			
		}		
		
		return "front/ordermanagerok_info";
	}	
		
	
	/**
	 * 查询订单详情
	 * @param od
	 * @param session
	 * @param model
	 * @return
	 */
	@RequestMapping("detailslist")
	public String orderDetailslist(OrderDetail od,HttpSession session,Model model){
		
		model.addAttribute("list", omService.detailslist(od));
		
		return "front/orderdetails_info";
	}

}
